package com.edu.bhu.admin.service.impl;

import java.util.List;

import com.edu.bhu.common.utils.DateUtils;
import com.edu.bhu.common.utils.SerialUtils;
import com.edu.bhu.common.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.edu.bhu.admin.mapper.CosOrderMapper;
import com.edu.bhu.admin.domain.CosOrder;
import com.edu.bhu.admin.service.ICosOrderService;
import com.edu.bhu.common.core.text.Convert;

/**
 * 订单Service业务层处理
 * 
 * @author wangjinao
 * @date 2022-03-17
 */
@Service
public class CosOrderServiceImpl implements ICosOrderService 
{
    @Autowired
    private CosOrderMapper cosOrderMapper;

    /**
     * 查询订单
     * 
     * @param orderId 订单主键
     * @return 订单
     */
    @Override
    public CosOrder selectCosOrderByOrderId(Long orderId)
    {
        return cosOrderMapper.selectCosOrderByOrderId(orderId);
    }

    /**
     * 查询订单列表
     * 
     * @param cosOrder 订单
     * @return 订单
     */
    @Override
    public List<CosOrder> selectCosOrderList(CosOrder cosOrder)
    {
        return cosOrderMapper.selectCosOrderList(cosOrder);
    }

    /**
     * 新增订单
     * 
     * @param cosOrder 订单
     * @return 结果
     */
    @Override
    public int insertCosOrder(CosOrder cosOrder)
    {
        cosOrder.setGenDate(DateUtils.getNowDate());
        cosOrder.setUserId(ShiroUtils.getSysUser().getUserId());
        return cosOrderMapper.insertCosOrder(cosOrder);
    }

    /**
     * 修改订单
     * 
     * @param cosOrder 订单
     * @return 结果
     */
    @Override
    public int updateCosOrder(CosOrder cosOrder)
    {
        return cosOrderMapper.updateCosOrder(cosOrder);
    }

    /**
     * 批量删除订单
     * 
     * @param orderIds 需要删除的订单主键
     * @return 结果
     */
    @Override
    public int deleteCosOrderByOrderIds(String orderIds)
    {
        return cosOrderMapper.deleteCosOrderByOrderIds(Convert.toStrArray(orderIds));
    }

    /**
     * 删除订单信息
     * 
     * @param orderId 订单主键
     * @return 结果
     */
    @Override
    public int deleteCosOrderByOrderId(Long orderId)
    {
        return cosOrderMapper.deleteCosOrderByOrderId(orderId);
    }
}
